package model

import (
	"KumquatDrivesServices/global"
	"gorm.io/gorm"
	"time"
)

type Model struct {
	ID        SnowflakeIdType `gorm:"primaryKey" json:"-"`
	CreatedAt time.Time       `json:"-"`
	UpdatedAt time.Time       `json:"-"`
}

func (m *Model) BeforeCreate(tx *gorm.DB) (err error) {
	if m.ID == 0 {
		m.ID = SnowflakeIdType(global.SnowflakeNode.Generate())
	}
	return
}
